package savehalloween;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;


public class GameMidlet extends MIDlet implements CommandListener{

	private Command exitCommand; // The exit command
    private Display display;     // The display for this MIDlet
    private PlayCanvas gameCanvas;
    
	public GameMidlet() {
		display = Display.getDisplay(this);
        exitCommand = new Command("GET OUTTA HERE!", Command.EXIT, 0);
        
        gameCanvas = new PlayCanvas();
	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
		// TODO Auto-generated method stub

	}

	
	protected void pauseApp() {
		// TODO Auto-generated method stub
		
		try {
			gameCanvas.wait();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	protected void startApp() throws MIDletStateChangeException {
		// TODO Auto-generated method stub
        display.setCurrent(gameCanvas);
        gameCanvas.start();

	}
	
	public void commandAction(Command c, Displayable s) {
        if (c == exitCommand) {
            try {
				destroyApp(false);
			} catch (MIDletStateChangeException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            notifyDestroyed();
        } 
    }

}
